﻿
namespace SomethingSpacialClassLib.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.Server;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;


    // Implements application logic using the SUGWTKEntities1 context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public partial class SomethingSpacialService : LinqToEntitiesDomainService<SUGWTKEntities1>
    {

        #region Event Methods
        //// TODO: Consider
        //// 1. Adding parameters to this method and constraining returned results, and/or
        //// 2. Adding query methods taking different parameters.
        //public IQueryable<Event> GetEvents()
        //{
        //    return this.ObjectContext.Events;
        //}

        //public IQueryable<Event> GetEventLatest()
        //{
        //    return this.ObjectContext.Events.OrderByDescending(e => e.EVT_Start_Date).Take(1);
        //}

        //public IQueryable<Event> GetEventsPrevious()
        //{
        //    return this.ObjectContext.Events.OrderByDescending(e => e.EVT_Start_Date);
        //}


        //public void InsertEvent(Event @event)
        //{
        //    if ((@event.EntityState != EntityState.Added))
        //    {
        //        if ((@event.EntityState != EntityState.Detached))
        //        {
        //            this.ObjectContext.ObjectStateManager.ChangeObjectState(@event, EntityState.Added);
        //        }
        //        else
        //        {
        //            this.ObjectContext.AddToEvents(@event);
        //        }
        //    }
        //}

        //public void UpdateEvent(Event currentEvent)
        //{
        //    if ((currentEvent.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.AttachAsModified(currentEvent, this.ChangeSet.GetOriginal(currentEvent));
        //    }
        //}

        //public void DeleteEvent(Event @event)
        //{
        //    if ((@event.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.Attach(@event);
        //    }
        //    this.ObjectContext.DeleteObject(@event);
        //} 
        #endregion Event Methods

        #region EventFeedback Methods
        //public IQueryable<EventFeedback> GetEventFeedbacksNext(int EventFeedbackID)
        //{
        //    return this.ObjectContext.EventFeedbacks.Where(e => e.EFB_ID > EventFeedbackID).OrderBy(e => e.EFB_ID).Take(1);
        //}
        //public IQueryable<EventFeedback> GetEventFeedbacksLatest(int EventID)
        //{
        //    return this.ObjectContext.EventFeedbacks.Where(e => e.EFB_EventID == EventID).OrderByDescending(e => e.EFB_ID).Take(1);
        //}

        ////JL: Added this to get All the Latest Feedbacks from an Event
        //public IQueryable<EventFeedback> GetAllEventFeedbacks(int EventID)
        //{
        //    //var EventFeedBacks = this.ObjectContext.EventFeedbacks;
        //    var EventFeedBacks = this.ObjectContext.EventFeedbacks.Where(e => e.EFB_EventID == EventID).OrderByDescending(e => e.EFB_ID);

        //    return EventFeedBacks;
        //}

        ////We get the latest Feedbacks from a concrete feedback
        //public IQueryable<EventFeedback> GetAllEventFeedbacksFromId(int EventID, int Id)
        //{
        //    var LatestEventFeedbacks = from ef in this.ObjectContext.EventFeedbacks
        //                               where (ef.EFB_EventID == EventID &&
        //                                      ef.EFB_ID > Id)
        //                               orderby ef.EFB_ID
        //                               select ef;

        //    return LatestEventFeedbacks;
        //}

        //// TODO: Consider
        //// 1. Adding parameters to this method and constraining returned results, and/or
        //// 2. Adding query methods taking different parameters.
        //public IQueryable<EventFeedback> GetEventFeedbacks()
        //{
        //    return this.ObjectContext.EventFeedbacks;
        //}

        //public void InsertEventFeedback(EventFeedback eventFeedback)
        //{
        //    if ((eventFeedback.EntityState != EntityState.Added))
        //    {
        //        if ((eventFeedback.EntityState != EntityState.Detached))
        //        {
        //            this.ObjectContext.ObjectStateManager.ChangeObjectState(eventFeedback, EntityState.Added);
        //        }
        //        else
        //        {
        //            this.ObjectContext.AddToEventFeedbacks(eventFeedback);
        //        }
        //    }
        //}

        //public void UpdateEventFeedback(EventFeedback currentEventFeedback)
        //{
        //    if ((currentEventFeedback.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.AttachAsModified(currentEventFeedback, this.ChangeSet.GetOriginal(currentEventFeedback));
        //    }
        //}

        //public void DeleteEventFeedback(EventFeedback eventFeedback)
        //{
        //    if ((eventFeedback.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.Attach(eventFeedback);
        //    }
        //    this.ObjectContext.DeleteObject(eventFeedback);
        //} 
        #endregion

        #region Job Methods

        //// TODO: Consider
        //// 1. Adding parameters to this method and constraining returned results, and/or
        //// 2. Adding query methods taking different parameters.
        //public IQueryable<Job> GetJobs()
        //{
        //    return this.ObjectContext.Jobs;
        //}

        //public void InsertJob(Job job)
        //{
        //    if ((job.EntityState != EntityState.Added))
        //    {
        //        if ((job.EntityState != EntityState.Detached))
        //        {
        //            this.ObjectContext.ObjectStateManager.ChangeObjectState(job, EntityState.Added);
        //        }
        //        else
        //        {
        //            this.ObjectContext.AddToJobs(job);
        //        }
        //    }
        //}

        //public void UpdateJob(Job currentJob)
        //{
        //    if ((currentJob.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.AttachAsModified(currentJob, this.ChangeSet.GetOriginal(currentJob));
        //    }
        //}

        //public void DeleteJob(Job job)
        //{
        //    if ((job.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.Attach(job);
        //    }
        //    this.ObjectContext.DeleteObject(job);
        //} 
        #endregion

        #region Location Methods

        //// TODO: Consider
        //// 1. Adding parameters to this method and constraining returned results, and/or
        //// 2. Adding query methods taking different parameters.
        //public IQueryable<Location> GetLocations()
        //{
        //    return this.ObjectContext.Locations;
        //}

        //public void InsertLocation(Location location)
        //{
        //    if ((location.EntityState != EntityState.Added))
        //    {
        //        if ((location.EntityState != EntityState.Detached))
        //        {
        //            this.ObjectContext.ObjectStateManager.ChangeObjectState(location, EntityState.Added);
        //        }
        //        else
        //        {
        //            this.ObjectContext.AddToLocations(location);
        //        }
        //    }
        //}

        //public void UpdateLocation(Location currentLocation)
        //{
        //    if ((currentLocation.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.AttachAsModified(currentLocation, this.ChangeSet.GetOriginal(currentLocation));
        //    }
        //}

        //public void DeleteLocation(Location location)
        //{
        //    if ((location.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.Attach(location);
        //    }
        //    this.ObjectContext.DeleteObject(location);
        //} 
        #endregion

        #region Sponsor Methods
        //// TODO: Consider
        //// 1. Adding parameters to this method and constraining returned results, and/or
        //// 2. Adding query methods taking different parameters.
        //public IQueryable<Sponsor> GetSponsors()
        //{
        //    return this.ObjectContext.Sponsors;
        //}

        //public void InsertSponsor(Sponsor sponsor)
        //{
        //    if ((sponsor.EntityState != EntityState.Added))
        //    {
        //        if ((sponsor.EntityState != EntityState.Detached))
        //        {
        //            this.ObjectContext.ObjectStateManager.ChangeObjectState(sponsor, EntityState.Added);
        //        }
        //        else
        //        {
        //            this.ObjectContext.AddToSponsors(sponsor);
        //        }
        //    }
        //}

        //public void UpdateSponsor(Sponsor currentSponsor)
        //{
        //    if ((currentSponsor.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.AttachAsModified(currentSponsor, this.ChangeSet.GetOriginal(currentSponsor));
        //    }
        //}

        //public void DeleteSponsor(Sponsor sponsor)
        //{
        //    if ((sponsor.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.Attach(sponsor);
        //    }
        //    this.ObjectContext.DeleteObject(sponsor);
        //} 
        #endregion

        #region UserGroup Methods
        //// TODO: Consider
        //// 1. Adding parameters to this method and constraining returned results, and/or
        //// 2. Adding query methods taking different parameters.
        //public IQueryable<UserGroup> GetUserGroups()
        //{
        //    return this.ObjectContext.UserGroups;
        //}

        //public IQueryable<UserGroup> GetUserGroupsFirst()
        //{
        //    return this.ObjectContext.UserGroups.OrderByDescending(e => e.UG_Id).Take(1);
        //}


        //public void InsertUserGroup(UserGroup userGroup)
        //{
        //    if ((userGroup.EntityState != EntityState.Added))
        //    {
        //        if ((userGroup.EntityState != EntityState.Detached))
        //        {
        //            this.ObjectContext.ObjectStateManager.ChangeObjectState(userGroup, EntityState.Added);
        //        }
        //        else
        //        {
        //            this.ObjectContext.AddToUserGroups(userGroup);
        //        }
        //    }
        //}

        //public void UpdateUserGroup(UserGroup currentUserGroup)
        //{
        //    if ((currentUserGroup.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.AttachAsModified(currentUserGroup, this.ChangeSet.GetOriginal(currentUserGroup));
        //    }
        //}

        //public void DeleteUserGroup(UserGroup userGroup)
        //{
        //    if ((userGroup.EntityState == EntityState.Detached))
        //    {
        //        this.ObjectContext.Attach(userGroup);
        //    }
        //    this.ObjectContext.DeleteObject(userGroup);
        //} 
        #endregion

    }
}


